import java.util.ArrayList;
import java.util.Random;

public class main2 {
    public static void main(String[] args) {
        BST<Integer> bst = new BST<>();
        // 添加随机元素
        Random random = new Random();
        int n = 1000;

        for (int i = 0; i < n; i++) {
            bst.add2(random.nextInt(10000));
        }

        ArrayList<Integer> nums = new ArrayList<>();
        // test removeMin()
        while (!bst.isEmpty()){
            nums.add(bst.removeMin());
        }
        System.out.println(nums);

        for (int i = 1; i < nums.size(); i++) {
            if (nums.get(i-1) > nums.get(i)) {
                throw new IllegalArgumentException("Error");
            }
        }
        System.out.println("removeMin test completed.");

        // test removeMax()
        for (int i = 0; i < n; i++) {
            bst.add2(random.nextInt(10000));
        }

        nums = new ArrayList<>();

        while (!bst.isEmpty()){
            nums.add(bst.removeMax());
//            System.out.println(bst.removeMax());
        }
        System.out.println(nums);

        for (int i = 1; i < nums.size(); i++) {
            if (nums.get(i-1) < nums.get(i)) {
                throw new IllegalArgumentException("Error");
            }
        }
        System.out.println("removeMax test completed.");

    }
}
